/*
 * Copyright [2010] [Daniel H. Cavalcanti]
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.collections;

/**
 * Defines the interface for a (min/max) heap.
 *
 * @author Daniel Cavalcanti
 */
public interface Heap<E> {

    /**
     * Returns the number of elements in the heap.
     *
     * @return The number of elements in the heap.
     */
    public int size();

    /**
     * Determines if the heap contains at least one element or not.
     *
     * @return true iff the heap is empty; otherwise, false.
     */
    public boolean isEmpty();

    /**
     * Peeks the root element.
     * 
     * @return The root element if heap is not empty; otherwise, null.
     */
    public E peek();

    /**
     * Inserts an element into the heap.
     * 
     * @param e The element to insert.
     * @throws NullPointerException If the element is null.
     */
    public void insert(E e)
    throws NullPointerException;

    /**
     * Removes and return the root element.
     * 
     * @return The root element of the heap is not null; otherwise, null.
     */
    public E remove();

}
